Imports System.Data.SqlClient
Partial Class Secure_Bulletin_CMS
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Dim con As SqlConnection
            Dim cmd As SqlCommand
            Dim rdr As SqlDataReader

            Dim urlVar As String = Nothing
            Dim titleVar As String = Nothing
            Dim pageidVar As Integer = Nothing
            Dim pageSubtitleVar As String = Nothing
            Dim pageDescriptionVar As String = Nothing

            con = New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("sqlConn"))
            cmd = New SqlCommand("select * from pages where CMSPage = 1", con)
            con.Open()
            rdr = cmd.ExecuteReader()
            While rdr.Read
                If rdr("url") = "index.aspx" Then
                    pageidVar = rdr(ID)
                End If
                pageNavigationLabel.Text &= "<li><a href=" & rdr("url") & ">" & rdr("title") & "</a></li>"
            End While
            rdr.Close()
            con.Close()
        End If
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim strConnection As String = System.Configuration.ConfigurationManager.AppSettings("sqlConn")
        Dim objConnection As New SqlConnection(strConnection)
        Dim UpdateStr As String = "INSERT INTO bulletins (bulletin_type, bulletin_date, bulletin_text, more_url, bulletin_title, Active) VALUES ('" & bulletinType.Text & "', '" & BulletinDate.Text & "', '" & BulletinText.Text & "', '" & MoreUrl.Text & "', '" & BulletinTitle.Text & "', '" & isActive.Checked & "')"
        Dim dbCommand As New SqlCommand(UpdateStr, objConnection)
        objConnection.Open()
        dbCommand.ExecuteNonQuery()
        objConnection.Close()
        Label1.ForeColor = Drawing.Color.Black
    End Sub
End Class
